Skip to content

Improve paganin filter method's memory estimation #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Sep 26, 2024

Conversation

yousefmoazzam
Copy link
Collaborator

@yousefmoazzam yousefmoazzam commented Sep 20, 2024

Fixes #430

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have made corresponding changes to the documentation

The fact that the 2D FFT used in `paganin_filter_tomopy()` is C2C, in
conjunction with the use of `overwrite_x=True`, means that the result is
able to be written into the input array. Thus, no new array is created
to hold the result of the 2D FFT.
Also move variable in final sum to match the order in which the
allocations appear in the method.
The padded `float32` array is cast to `complex64`, and the variable
originally assigned to the `float32` version is reassigned to the
`complex64` version.

The reassigned variable was the only thing referring to the `float32`
array, so the ref count of it drops to 0 and is deallocated.

The padded `float32` array gets deallocated early enough in the method
that it doesn't contribute to the *peak* memory usage of the paganin
filter method, which was verified by checking:
- the output of `LineProfileHook` when running the method
- the allocations and deallocations reported by the custom
  `MaxMemoryHook` in the tests during the method's execution
The method's code defines the reciprocal grid based on the padded
projections `complex64` array shape. However, the memory estimator was
incorrectly calculating the number of bytes the reciprocal grid takes
using the unpadded `float32` array shape.
@yousefmoazzam yousefmoazzam changed the title Improve paganin_filter_tomopy memory estimation Improve paganin filter method's memory estimation Sep 23, 2024
@yousefmoazzam
Copy link
Collaborator Author

Ok, both paganin filter method's memory hook tests now pass on:

  • IRIS CI
  • my local workstation pc0074
  • a V100 node
  • a P100 node

so I'm hopeful that at least the bulk of the significant memory allocations in both methods are accounted for correctly in their respective estimators.

Before I mark this as ready to review I will write up an issue on the changes in b32a2c8, because they will surely raise some questions and thus require a bit of an explanation...

@yousefmoazzam yousefmoazzam marked this pull request as ready for review September 24, 2024 11:51
@yousefmoazzam yousefmoazzam merged commit 0852f3b into main Sep 26, 2024
8 checks passed
@yousefmoazzam yousefmoazzam deleted the improve-paganin-memory-estimation branch September 26, 2024 11:15
yousefmoazzam added a commit to DiamondLightSource/httomo-backends that referenced this pull request Dec 11, 2024
Reflects changes to paganin filter memory estimators in
DiamondLightSource/httomo#454.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fixing memory estimators for Paganin
1 participant